﻿<%@ Page Language="C#" MasterPageFile="../../MasterPage.Master" AutoEventWireup="true" CodeBehind="ICM_Receives.aspx.cs" Inherits="KPIS.GERP.GIMS.APP.APP_UI.Form.ICM_Receives" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register TagPrefix="custom" Namespace="KPIS.Customs.UI" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function onTextChangeGeneral(sender) {
                if (sender.get_value() == "") {
                    sender.set_text("");
                }
            }
            function openWin() {
                Page_ClientValidate('Normal');
                var comboReceiveType = $find('<%= cbReceiveType.ClientID %>');
                if (Page_IsValid) {
                    //CloseTooltip();
                    var oWnd = radopen('../Edit_Form/ICM_Receive_Object.aspx?pt=' + comboReceiveType.get_value() + '&ptn=' + comboReceiveType.get_text() + '&um=2', "WindowDetail");
                }
            }
            function openReceiveStatusEdit(ReceiveSeq) {
                Page_ClientValidate('Normal');
                var comboReceiveType = $find('<%= cbReceiveType.ClientID %>');
                if (Page_IsValid) {
                    //CloseTooltip();
                    var oWnd = radopen('../Edit_Form/ICM_Receive_Object.aspx?pt=' + comboReceiveType.get_value() + '&ptn=' + comboReceiveType.get_text() + '&um=2', "WindowDetail");
                }
            }
            function closeRadWindow(sender, args) {
                $find("<%= RadManager1.ClientID %>").ajaxRequest('CloseWindow');
            }
            function RowDbClick(sender, eventArgs) {
                var hiddenElement = document.getElementById("<%= hdSeq.ClientID %>");
                hiddenElement.value = eventArgs.getDataKeyValue("Seq");
                $find("<%= RadManager1.ClientID %>").ajaxRequest(hiddenElement.value);
            }

            function SeqClick(seq) {
                var hiddenElement = document.getElementById("<%= hdSeq.ClientID %>");
                hiddenElement.value = seq;
                $find("<%= RadManager1.ClientID %>").ajaxRequest(seq);
            }
            function CollapsePane() {
                var slidingZone = $find("<%= SlidingZone1.ClientID %>");
                var panes = slidingZone.GetPanes();
                slidingZone.collapsePane(panes[1].get_id());
            }   
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None" Skin="Outlook">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager runat="server" ID="RadManager1" OnAjaxRequest="RadManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="panelData">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="panelCommand" />
                    <telerik:AjaxUpdatedControl ControlID="panelData" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="panelCommand">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="panelCommand" />
                    <telerik:AjaxUpdatedControl ControlID="panelData" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnUser">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="btnUser"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
        
    <asp:Panel ID="panelHidden" runat="server">
        <asp:HiddenField ID="hdSeq" runat="server" Value="" />
    </asp:Panel>
    
    <telerik:RadSplitter id="RadSplitter1" runat="server" height="460" width="1000" Skin="Office2007" ResizeMode="EndPane">
        
        <telerik:RadSplitBar id="RadSplitBar1" runat="server" Visible="false"></telerik:RadSplitBar>
        <telerik:RadPane id="PaneData" runat="server" Scrolling="None">
            <table width="1000" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <asp:Panel ID="panelCommand" runat="server"> 
                            <div class="bigModulePaneFull">
                                <div class="bigModuleBottomPaneFull">
                                    <table cellpadding="0" cellspacing="0" >
                                        <tr class="command-list">
                                            <td class="command-item" style="border: none">
                                                <asp:LinkButton ID="ShowGrid" runat="server" CssClass="LinkButton" onclick="ShowGrid_Click" CausesValidation="false">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/table.gif" />&nbsp;&nbsp;แสดงข้อมูลทั้งหมด
                                                </asp:LinkButton>                        
                                            </td>
                                            <td class="command-item">
                                                <asp:LinkButton ID="AddNew" runat="server" CssClass="LinkButton" onclick="AddNew_Click">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/AddRecord.gif" />&nbsp;&nbsp;เพิ่มข้อมูลใหม่
                                                </asp:LinkButton>
                                            </td>
                                            <td class="command-item">
                                                <asp:LinkButton ID="Edit" runat="server" CssClass="LinkButton"  visible="false" OnClick="Edit_Click">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Edit.gif" />&nbsp;&nbsp;แก้ไขข้อมูล
                                                </asp:LinkButton>
                                            </td>
                                            <td class="command-item">
                                                <asp:LinkButton ID="Delete" runat="server" CssClass="LinkButton" OnClientClick="javascript:return confirm('ยืนยันการลบข้อมูลที่เลือก')" OnClick="Delete_Click">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Delete.gif" />&nbsp;&nbsp;ลบข้อมูล
                                                </asp:LinkButton>
                                            </td>
                                            <td class="command-item">
                                                <asp:LinkButton ID="AddNewSave" runat="server" CssClass="LinkButton" Visible="false" onclick="AddNewSave_Click">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cmd_Save.gif" />&nbsp;&nbsp;บันทึกข้อมูล
                                                </asp:LinkButton>
                                            </td>
                                            <%--<td class="command-item">
                                                <asp:LinkButton ID="EditSave" runat="server" CssClass="LinkButton" Visible="false" onclick="EditSave_Click">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cmd_Save.gif" />&nbsp;&nbsp;บันทึกข้อมูล
                                                </asp:LinkButton>
                                            </td>--%>
                                            <td class="command-item">
                                                <asp:LinkButton ID="Cancel" runat="server" CssClass="LinkButton" Visible="false" onclick="Cancel_Click">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cancel.gif" />&nbsp;&nbsp;ยกเลิก
                                                </asp:LinkButton>
                                            </td>
                                            <td class="command-item">
                                                <asp:LinkButton ID="Help" runat="server" CssClass="LinkButton" Visible="false" CausesValidation="false">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Tree/help3.gif" />&nbsp;&nbsp;ช่วยเหลือ
                                                </asp:LinkButton>
                                            </td>
                                            <%--<td class="command-item">
                                                <asp:LinkButton ID="Recycle" runat="server" CssClass="LinkButton" Visible="true" 
                                                    OnClientClick="javascript:radopen('../Delete_Form/ICM_Master_Resource_Type.aspx', 'WindowDelete');">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Refresh.gif" width="14" height="14"/>&nbsp;&nbsp;กู้ข้อมูล
                                                </asp:LinkButton>
                                            </td>--%>
                                        </tr>
                                    </table>
                                </div>
                            </div>                                
                        </asp:Panel>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Panel ID="panelData" runat="server">
                            <div class="bigModulePaneFull">
                                <div class="bigModuleBottomPaneFull">
                                    <asp:Panel ID="panelHeaderList" runat="server">
                                        <div class="header-grid">
                                            <asp:Label ID="lblHeaderList" runat="server" Text="รายการรับพัสดุเข้าคลัง" ></asp:Label>
                                        </div>
                                    </asp:Panel>                                    
                                    <asp:Panel CssClass="panelGrid" ID="panelGrid" runat="server" ScrollBars="Auto" Visible="true" > 
                                        <div align="center">                                   
                                        <telerik:RadGrid ID="grdInventory" 
                                            runat="server" 
                                            AutoGenerateColumns="false"
                                            AllowMultiRowEdit="false" 
                                            AllowMultiRowSelection="true" 
                                            ShowStatusBar="true"
                                            Width="930px" Height="330px" 
                                            AllowPaging="true" 
                                            AllowFilteringByColumn="false"
                                            GroupingSettings-GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;"
                                            GroupingSettings-GroupContinuedFormatString=""
                                            GroupingSettings-GroupContinuesFormatString=""
                                            GroupingSettings-GroupSplitFormat="" PageSize ="7" 
                                            OnNeedDataSource="grdInventory_NeedDataSource" 
                                            OnItemCommand="grdInventory_ItemCommand" align ="left">
                                            <MasterTableView AllowMultiColumnSorting="True" CellSpacing="-1" GroupLoadMode="Client"
                                            ShowGroupFooter="true" 
                                            DataKeyNames="trans_mas_seq" NoMasterRecordsText="< ไม่มีข้อมูล >" GroupsDefaultExpanded="true">
                                            <RowIndicatorColumn>
                                                <HeaderStyle Width="20px" />
                                            </RowIndicatorColumn>
                                            <ExpandCollapseColumn>
                                                <HeaderStyle Width="20px" />
                                            </ExpandCollapseColumn>
                                            <GroupByExpressions>
                                                <telerik:GridGroupByExpression>
                                                    <GroupByFields>
                                                        <telerik:GridGroupByField FieldName="created_when" HeaderText="เลขที่ทำรายการ" />
                                                    </GroupByFields>
                                                    <SelectFields>
                                                        <telerik:GridGroupByField FieldName="created_when" HeaderText="วันที่ทำรายการ"  />
                                                    </SelectFields>
                                                </telerik:GridGroupByExpression>
                                            </GroupByExpressions>
                                            <Columns>   
                                                <telerik:GridTemplateColumn AllowFiltering="false" UniqueName="Delete" HeaderText="ลบ" HeaderStyle-Width="35px" HeaderStyle-Font-Bold="false" HeaderStyle-HorizontalAlign="Center"> 
                                                    <FilterTemplate></FilterTemplate>
                                                    <ItemTemplate>
                                                         <asp:ImageButton ID="cmdDelete" runat="server" 
                                                            CommandName="DataDelete"
                                                            ImageUrl="~/App_UI/Image/Grid/Delete.gif" 
                                                            OnClientClick="javascript:return confirm('ยืนยันการลบข้อมูลที่เลือก')"
                                                            ToolTip="ลบรายการ" width="17" /> 
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                                <telerik:GridBoundColumn DataField="icm_receive_seq" 
                                                    HeaderText="icm_receive_seq" UniqueName="icm_receive_seq"
                                                    FilterControlWidth="100%" AutoPostBackOnFilter="true" 
                                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" Visible="false" 
                                                    HeaderStyle-Font-Bold="false" HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridTemplateColumn  
                                                    HeaderText="รหัสอ้างอิงการรับเข้า" 
                                                    ShowFilterIcon="false" 
                                                    HeaderStyle-Font-Bold="false"
                                                    HeaderStyle-Width="100%" 
                                                    HeaderStyle-HorizontalAlign="Center" 
                                                    FilterControlWidth="100%" UniqueName="icm_receive_code">
                                                    <ItemTemplate >                                                                                                                           
                                                            <asp:LinkButton ID="targetControl" runat="server" Text='<%# Eval("icm_receive_code") %>' 
                                                            OnClientClick='<%# string.Format("return openReceiveStatusEdit(\"{0}\");", Eval("icm_receive_seq")) %>'  > 
                                                            </asp:LinkButton>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                                <telerik:GridBoundColumn DataField="icm_receive_name" 
                                                    HeaderText="เรื่อง" UniqueName="icm_receive_name"
                                                    FilterControlWidth="100%" 
                                                    AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" 
                                                    ShowFilterIcon="false" 
                                                    HeaderStyle-Width="130px"
                                                    HeaderStyle-Font-Bold="false" 
                                                    HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>      
                                                <telerik:GridBoundColumn DataField="icm_wh_name" 
                                                    HeaderText="คลังพัสดุ" UniqueName="icm_wh_name"
                                                    FilterControlWidth="100%" 
                                                    AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" 
                                                    ShowFilterIcon="false" 
                                                    HeaderStyle-Width="130px"
                                                    HeaderStyle-Font-Bold="false" 
                                                    HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="job_site_name" 
                                                    HeaderText="หน่วยงาน" UniqueName="job_site_name"
                                                    FilterControlWidth="100%" 
                                                    AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" 
                                                    ShowFilterIcon="false" 
                                                    HeaderStyle-Width="130px"
                                                    HeaderStyle-Font-Bold="false" 
                                                    HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="icm_res_type_name" 
                                                    HeaderText="ประเภทพัสดุ" 
                                                    UniqueName="icm_res_type_name"
                                                    FilterControlWidth="100%" 
                                                    AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="70px" 
                                                    HeaderStyle-Font-Bold="false" HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="receive_type_name" 
                                                    HeaderText="ประเภทการรับเข้า" UniqueName="receive_type_name"
                                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="130px"
                                                    HeaderStyle-Font-Bold="false" HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>
<%--                                                <telerik:GridBoundColumn DataField="status_name" 
                                                    HeaderText="สถานะ" UniqueName="status_name"
                                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"HeaderStyle-Width="77px"
                                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                                                    HeaderStyle-Font-Bold="false" HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>--%>

                                            </Columns>
                                            <PagerStyle Mode="NumericPages" AlwaysVisible="true" 
                                                FirstPageToolTip="กลับหน้าแรก" LastPageToolTip="ไปหน้าสุดท้าย" 
                                                NextPagesToolTip="หน้าถัดไป" NextPageToolTip="หน้าถัดไป" 
                                                PrevPagesToolTip="ย้อนกลับ" PrevPageToolTip="ย้อนกลับ" />
                                            </MasterTableView>
                                            <GroupingSettings GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;" 
                                                GroupContinuedFormatString="" GroupContinuesFormatString="" 
                                                GroupSplitFormat="" />
                                            <ClientSettings EnableRowHoverStyle="True">
                                                <Selecting AllowRowSelect="true" />
                                                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                                            </ClientSettings>
                                      </telerik:RadGrid>
                                    </div>
                                    </asp:Panel>
                                    <asp:Panel ID="panelList_Detail" runat="server" CssClass="panelList" ScrollBars="Auto">
                                        <custom:ConfiguratorPanel runat="server" ID="ConfiguratorPanel1" Title="รายละเอียดการตรวจรับ" Width="98%">
                                            <table width="98%">
                                                <tr>
                                                    <td>
                                                    
                                                    </td>
                                                </tr>
                                            </table>
                                        </custom:ConfiguratorPanel>
                                    </asp:Panel>
                                    <asp:Panel runat="server" ID="PanelAddData" Visible="false" CssClass="panelList">
                                        <ul class="formList" id="Ul1">                                             
                                            <div class="formList-detail">
                                                <table>
                                                    <tr>
                                                        <td width = "150px" valign="top">
                                                            ประเภทการรับเข้า :
                                                        </td>
                                                        <td>
                                                            <telerik:RadComboBox 
                                                                ID="cbReceiveType" 
                                                                runat="server" 
                                                                AllowCustomText="true" 
                                                                AutoPostBack="true" 
                                                                CausesValidation="false" 
                                                                DataTextField="receive_type_name" 
                                                                DataValueField="receive_type_seq" 
                                                                EmptyMessage="... เลือกประเภทการรับเข้า ..." 
                                                                Filter="Contains" 
                                                                OnClientTextChange="onTextChangeGeneral"                                                                 
                                                                Width="200px">
                                                            </telerik:RadComboBox>
                                                        </td>
                                                        <td>
                                                            <asp:RequiredFieldValidator 
                                                                ID="ValcbReceiveType" 
                                                                runat="server" 
                                                                ControlToValidate="cbReceiveType" 
                                                                SetFocusOnError="True" 
                                                                Display="Dynamic" 
                                                                ErrorMessage="* กรุณาระบุประเภทการรับเข้า *" 
                                                                ValidationGroup="Normal">
                                                            </asp:RequiredFieldValidator>
                                                        </td>                                                       
                                                    </tr>
                                                </table>
                                            </div>
                                            <div>
                                                <table>
                                                    <tr>
                                                        <td>
                                                            &nbsp;&nbsp;
                                                        </td>
                                                    </tr>
                                                    <tr align="center">
                                                        <td width="450px">
                                                            <asp:LinkButton ID="btnAddNew" runat="server" Text="สร้างรายการ" 
                                                                CssClass="form-button" OnClientClick="openWin(); return false;" 
                                                                ValidationGroup="Normal">
                                                            </asp:LinkButton>                                                          
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </ul>
                                    </asp:Panel>
                                </div>
                            </div>
                        </asp:Panel>
                                       
                    </td>
                </tr>
            </table>
        </telerik:RadPane>        
    </telerik:RadSplitter>
    <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true" 
        runat="server" Skin="Vista" Modal="true" KeepInScreenBounds="true" Style="z-index: 7001">
        <Windows>
            <telerik:RadWindow ID="WindowDetail" runat="server" 
                Width="1024px" Height="600px" Behaviors="Default" 
                OnClientClose="closeRadWindow">
            </telerik:RadWindow>            
        </Windows>
    </telerik:RadWindowManager>
</asp:Content>